package utils.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseConnectionTest {

    public static boolean testConnection(String ip, String port, String username, String password) {
        String url = "jdbc:mysql://" + ip + ":" + port + "/mysql"; // 使用mysql系统数据库

        try (Connection conn = DriverManager.getConnection(url, username, password)) {
            return true;
        } catch (SQLException e) {
            System.err.println("Failed to connect to the database.");
            return false;
        }
    }
}

